/**
 * Project Name:swt-hello <br/>
 * File Name:App.java <br/>
 * Package Name:com.ftu.z <br/>
 */
package com.ftu.swt.basic1;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.graphics.Region;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;


/**
 * <p>  </p>
 * @version 1.0 2018年11月22日 mq 修改内容:初版
 */
public class UsingRegion {
    public static void main(String[] args) {
        final Display display = Display.getDefault();
        final Shell shell1 = new Shell(display, SWT.NO_TRIM);
        shell1.setText("shell1");
        shell1.setSize(400, 400);
        
        Region region = new Region(display);
        region.add(new Rectangle(10, 10, 10, 100));
        region.add(new Rectangle(10, 100, 100, 10));
        region.add(new Rectangle(10, 10, 100, 10));
        region.add(new Rectangle(100, 10, 10, 100));
        shell1.setRegion(region);
        shell1.setBackground(new Color(null, 255, 0, 0));
        shell1.addMouseListener(new MouseAdapter() {
            /* (non-Javadoc)
             * @see org.eclipse.swt.events.MouseAdapter#mouseDown(org.eclipse.swt.events.MouseEvent)
             */
            @Override
            public void mouseDown(MouseEvent e) {
                shell1.dispose();
            }
        });
        
        shell1.open();
        while(!shell1.isDisposed()) {
            if(!display.readAndDispatch()) {
                display.sleep();
            }
        }
        display.dispose();
        
    }

}
